using System;
using System.Windows.Forms;

namespace Eagleshoes.PackingBarcode.PackagingScan.Offline
{
    public partial class PackagingOfflineMenuForm : Form
    {
        public PackagingOfflineMenuForm()
        {
            InitializeComponent();
        }

        #region Events

        private void PackagingOfflineMenuForm_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                case Keys.F10:
                    Close();
                    break;
                case Keys.F1:
                    Scan();
                    break;
                case Keys.F2:
                    Import();

                    break;
                case Keys.F3:
                    Upload();
                    break;
            }
        }

        private void lv_ItemActivate(object sender, EventArgs e)
        {
            var lv1 = (ListView) sender;
            if (lv1.SelectedIndices.Count > 0)
            {
                ListViewItem lvi = lv1.Items[lv1.SelectedIndices[0]];
                if (lvi.Tag != null)
                {
                    var tag = lvi.Tag as string;
                    switch (tag)
                    {
                        case "1":
                            Scan();
                            break;
                        case "2":
                            Import();
                            break;
                        case "3":
                            Upload();
                            break;
                        case "0":
                            Close();
                            break;
                    }
                }
            }
        }

        #endregion

        #region Methods

        private void Scan()
        {
            var frm = new PackagingOfflineScanForm();
            frm.ShowDialog();
        }

        private void Import()
        {
            var frm = new ImportOfflineDataForm();
            frm.ShowDialog();
        }

        public void Upload()
        {
            var frm = new UploadOfflineDataForm();
            frm.ShowDialog();
        }

        #endregion
    }
}